﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

namespace Utility.Inspector
{
	public static class EditorToolUtility
	{
#if UNITY_EDITOR
		public static readonly string ProjectPrefix = PlayerSettings.companyName + "." + PlayerSettings.productName + ".";
#else
		public static readonly string ProjectPrefix = "";
#endif

		//bool
		public static bool GetBool (string key, bool defaultValue = false)
		{
#if UNITY_EDITOR
			return EditorPrefs.GetBool (ProjectPrefix + key, defaultValue);
#else
			return defaultValue;
#endif
		}

		public static void SetBool (string key, bool value)
		{
#if UNITY_EDITOR
			EditorPrefs.SetBool (ProjectPrefix + key, value);
#endif
		}

		//int
		public static int GetInt (string key, int defaultValue = 0)
		{
#if UNITY_EDITOR
			return EditorPrefs.GetInt (ProjectPrefix + key, defaultValue);
#else
			return defaultValue;
#endif
		}

		public static void SetInt (string key, int value)
		{
#if UNITY_EDITOR
			EditorPrefs.SetInt (ProjectPrefix + key, value);
#endif
		}

		//float
		public static float GetFloat (string key, float defaultValue = 0)
		{
#if UNITY_EDITOR
			return EditorPrefs.GetFloat (ProjectPrefix + key, defaultValue);
#else
			return defaultValue;
#endif
		}

		public static void SetFloat (string key, float value)
		{
#if UNITY_EDITOR
			EditorPrefs.SetFloat (ProjectPrefix + key, value);
#endif
		}

		//string
		public static string GetString (string key, string defaultValue = "")
		{
#if UNITY_EDITOR
			return EditorPrefs.GetString (ProjectPrefix + key, defaultValue);
#else
			return defaultValue;
#endif
		}

		public static void SetString (string key, string value)
		{
#if UNITY_EDITOR
			EditorPrefs.SetString (ProjectPrefix + key, value);
#endif
		}
	}
}